package exp1;

import java.util.Scanner;

public class SoundableInherit {

    private static Scanner reader = new Scanner(System.in);

    public static void main(String[] args) {
        String deviceName = reader.nextLine();
        String[] info = reader.nextLine().split(" ");
        int n = Integer.parseInt(reader.nextLine());

        Soundable device = null;

        if (deviceName.equals("Radio")) {
            device = new Radio(deviceName);
        } else if (deviceName.equals("MobilePhone")) {
            device = new MobilePhone(deviceName);
        }

        Person person = new Person(info[0], Integer.valueOf(info[1]), device);
        for (int i = 1; i <= n; i++) {
            String op = reader.nextLine();
            System.out.print(person);
            if (op.equals("A")) {
                person.getDivice().play();
            } else if (op.equals("B")) {
                person.getDivice().turnOff();
            } else if (op.equals("C")) {
                person.getDivice().turnUp();
            } else {
                person.getDivice().turnDown();
            }
        }
    }


}

class Person {
    private String name;
    private Integer age;
    private Soundable divice;

    public Person() {
    }

    public Person(String name, Integer age, Soundable divice) {
        this.name = name;
        this.age = age;
        this.divice = divice;
    }

    @Override
    public String toString() {
        return this.name + " " + this.age + " ";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Soundable getDivice() {
        return divice;
    }

    public void setDivice(Soundable divice) {
        this.divice = divice;
    }
}

interface Soundable {
    void play();

    void turnOff();

    void turnUp();

    void turnDown();

    String getName();
}

class Radio implements Soundable {

    private String name;

    public Radio() {
    }

    public Radio(String name) {
        this.name = name;
    }

    @Override
    public void play() {
        System.out.println("Play the Radio");
    }

    @Override
    public void turnOff() {
        System.out.println("Turn off the Radio");
    }

    @Override
    public void turnUp() {
        System.out.println("Turn up the Radio");
    }

    @Override
    public void turnDown() {
        System.out.println("Turn down the Radio");
    }

    @Override
    public String getName() {
        return this.name;
    }


}

class MobilePhone implements Soundable {

    private String name;

    public MobilePhone() {
    }

    public MobilePhone(String name) {
        this.name = name;
    }

    @Override
    public void play() {
        System.out.println("Play the MobilePhone");
    }

    @Override
    public void turnOff() {
        System.out.println("Turn off the MobilePhone");
    }

    @Override
    public void turnUp() {
        System.out.println("Turn up the MobilePhone");
    }

    @Override
    public void turnDown() {
        System.out.println("Turn down the MobilePhone");
    }


    @Override
    public String getName() {
        return this.name;
    }
}
